import {Pagination, PaginationData, User} from "../types/user.ts";
import {useAsync} from "../hooks/useAsync.ts";
import {useEffect} from "react";
import {getUsers} from "../api/user.ts";

export const useUser = (params: Pagination | User) => {
    const {run, ...result} = useAsync<PaginationData<User[]>>()
    useEffect(() => {
        run(getUsers(params))
    }, [params])
    return result
}